<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/btn.css">
<link rel="stylesheet" href="skin/activity.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body>
<div id="main" class="loading"></div>
</body>
<script>
	zy_init();
	function jump(id,name){
		localStorage['company_id']=id;
		localStorage['company_name']=name;
		uexWindow.open('company_show','0','company_show.html','2','', '',0);
	}
	
	function baoming(t){		
		if (c_l()) {
			if (!localStorage['u_mobile']) {
				uexWindow.alert('错误提示', '请先在会员中心绑定手机号码~', '确定');
				return false;
			}
			uexWindow.toast(1, 5, '报名中...', 0);
			var url = app_path+'index.php?m=iappActivity&c=app&a=baoming&id='+localStorage['activity_id']+'&userid='+localStorage['u_id']+'&acctoken='+localStorage['u_acctoken'];	
			uexXmlHttpMgr.open(2,'post',url,"8000");
			uexXmlHttpMgr.send(2);
		}else {
			gologin();
		}
	}
	
	function getMain(){
		var url = app_path+'index.php?m=iappActivity&c=app&a=show&id='+localStorage['activity_id'];
		uexXmlHttpMgr.open(1,'post',url,"8000");
		uexXmlHttpMgr.send(1);
	}
	window.uexOnload=function(type){
		if(!type){
			
			uexWindow.setBounce("1");
			uexWindow.showBounceView("0","#666","0");
			uexWindow.showBounceView("1","#666","0");
			
			uexXmlHttpMgr.onData = function(opId, status, data){
				if (opId == 1) {
					if(status==1){			
						uexXmlHttpMgr.close(opId);
						uexWindow.resetBounceView(opId);
						data = JSON.parse(data);
						if(data['status']=='OK'){
							var item=data['data'];
							
							var sd=new Date(item['start_time']*1000);
							var ed=new Date(item['end_time']*1000);
							
							var sName='进行中';
							if(item['start_time']>data['stime']){
								sName='未开始';
							}else if(item['end_time']<data['stime']){
								sName='已结束';
							}
							
							var div='<div class="show">';
							div+='<div class="loadimg"><img src="'+item['image']+'" class="hide" onload="this.className=\'\'" /></div>'+
							'<h1>'+item['title']+'</h1>'+
							'<h3>参与：<span id="bmnum">'+item['bmnum']+'</span><em>'+sName+'</em></h3>'+
							'<div class="button pb" ><button class="thoughtbot" onclick="baoming(this);" >报名参加</button></div>'+
							'<h3>活动时间</h3><pre>'+sd.getFullYear()+'-'+(sd.getMonth()+1)+'-'+sd.getDate()+' 至'+ed.getFullYear()+'-'+(ed.getMonth()+1)+'-'+ed.getDate()+'</pre>';
							for (i in item['content']) {
								div+='<h3>'+item['content'][i]['title']+'</h3><pre>'+item['content'][i]['description']+'</pre>';
							}
							if(item['lid']>0){
								div+='<div class="button pb" ><button class="thoughtbot" onclick="jump('+item['lid']+',\''+item['name']+'\');" >报名参加</button></div>';
							}
							div+='</div>';			
							$$("main").className = '';
							$$("main").innerHTML=div;
						}else{
							uexWindow.alert('错误提示',data['msg'],'确定');
							uexWindow.evaluateScript('activity_show',0,"uexWindow.close(0);");
						}
					}else if(status ==-1) {
						uexWindow.alert('错误提示','数据加载失败','确定');
					}
				}else if(opId == 2){
					uexWindow.closeToast();
					uexXmlHttpMgr.close(opId);
					if(status==1){
						data = JSON.parse(data);	
						if(data['status']=='OK'){
							$$('bmnum').innerHTML=data['bmnum'];
							uexWindow.alert('报名成功',data['msg'],'确定');
						}else if(data['status']=='NOTLOGIN'){
							gologin();
						}else{
							uexWindow.alert('报名失败',data['msg'],'确定');
						}
					}else if(status ==-1) {
						uexWindow.toast("0","5",'加载失败',2000);
					}
				}
			}
			
			getMain();			
		}
	}
	</script>
</html>